{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">公司名称：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$site.company}" name="company">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">售楼处：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$site.shoulou}" name="shoulou">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">地址：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$site.address}" name="address">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">电话：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$site.tel}" name="tel">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">网址：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$site.url}" name="url">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">ICP备案号：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$site.icp}" name="icp">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">楼盘销售二维码：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" id="upload1" placeholder="请点击后面的上传按钮" name="qrcode1" value="{$site.qrcode1}" style="width: 70%">
                <button type="button" class="btn btn-primary radius" onclick="layer_open('文件上传','{:\\think\\Url::build(\'Upload/index\', [\'id\' => \'upload1\'])}')">上传</button>
                <a onclick="$(this).attr('href', $('#upload1').val())" type="button" class="btn btn-success radius" data-lightbox="preview">预览</a>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">置业公司二维码：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" id="upload2" placeholder="请点击后面的上传按钮" name="qrcode2" value="{$site.qrcode2}" style="width: 70%">
                <button type="button" class="btn btn-primary radius" onclick="layer_open('文件上传','{:\\think\\Url::build(\'Upload/index\', [\'id\' => \'upload2\'])}')">上传</button>
                <a onclick="$(this).attr('href', $('#upload2').val())" type="button" class="btn btn-success radius" data-lightbox="preview">预览</a>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="button" class="btn btn-primary radius" id="tijiao">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="style"}
<link rel="stylesheet" href="__LIB__/lightbox2/css/lightbox.min.css">
{/block}
{block name="script"}
<script src="__LIB__/lightbox2/js/lightbox.min.js"></script>
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $("[name='status'][value='{$vo.status ?? '1'}']").attr("checked",true);

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            callback:function(ret){
                ajax_progress(ret);
            }
        });
    })

    $('#tijiao').on('click', function () {
        var company = $("input[name='company']").val(),
            shoulou = $("input[name='shoulou']").val(),
            address = $("input[name='address']").val(),
            tel = $("input[name='tel']").val(),
            url = $("input[name='url']").val(),
            icp = $("input[name='icp']").val(),
            qrcode1 = $("input[name='qrcode1']").val(),
            qrcode2 = $("input[name='qrcode2']").val();
        var data = {
            company: company,
            shoulou: shoulou,
            address: address,
            tel: tel,
            url: url,
            icp: icp,
            qrcode1: qrcode1,
            qrcode2: qrcode2
        };
        $.ajax({
            url: '/admin/site/save',
            type: 'post',
            dataType: 'json',
            data: {data: data},
            success: function (res) {
                if (res.code === 0) {
                    layer.msg('保存成功');
                }
            }
        });
    });
</script>
{/block}